﻿//-----------------------------------------------------------------------
// <copyright file="Supplier.cs" company="FER">
//     Copyright (c) All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace NMBP.Models
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Represents one supplier
    /// </summary>
    public class Supplier : IEqualityComparer<Supplier>
    {
        /// <summary>
        /// Gets or sets suppliers name
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets suppliers contact email
        /// </summary>
        public string Contact { get; set; }

        /// <summary>
        /// Gets or sets account number of supplier, used for paying
        /// </summary>
        public string AccountNumber { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether supplier is active
        /// </summary>
        public bool IsActive { get; set; }

        #region Implementation of IEqualityComparer<in Supplier>

        /// <summary>
        /// Determines whether the specified objects are equal.
        /// </summary>
        /// <returns>
        /// true if the specified objects are equal; otherwise, false.
        /// </returns>
        /// <param name="x">The first object of type <paramref name="T"/> to compare.</param><param name="y">The second object of type <paramref name="T"/> to compare.</param>
        public bool Equals(Supplier x, Supplier y)
        {
            if (x.GetHashCode() == y.GetHashCode())
            {
                if (x.Name == y.Name && x.IsActive == y.IsActive)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// Returns a hash code for the specified object.
        /// </summary>
        /// <returns>
        /// A hash code for the specified object.
        /// </returns>
        /// <param name="obj">The <see cref="T:System.Object"/> for which a hash code is to be returned.</param><exception cref="T:System.ArgumentNullException">The type of <paramref name="obj"/> is a reference type and <paramref name="obj"/> is null.</exception>
        public int GetHashCode(Supplier obj)
        {
            return obj.GetHashCode();
        }

        #endregion
    }
}
